hysop.backend.host.host_array module

class hysop.backend.host.host_array.HostArray(handle, backend, **kwds)[source]

Bases: Array

Host memory array wrapper. An HostArray is a numpy.ndarray work-alike that stores its data and performs its computations on CPU with numpy.

Build an HostArray instance.

Parameters:
  • handle (numpy.ndarray) – implementation of this array

  • backend (HostArrayBackend) – backend used to build this handle

  • kwds – arguments for base classes.

Notes

This should never be called directly by the user. Arrays should be constructed using array backend facilities, like zeros or empty. The parameters given here refer to a low-level method for instantiating an array.

property T

Same as self.transpose(), except that self is returned if self.ndim < 2.

as_symbolic_array(name, **kwds)[source]

Return a symbolic array variable that contain a reference to this array.

as_symbolic_buffer(name, **kwds)[source]

Return a symbolic buffer variable that contain a reference to this array.

astype(dtype, order=SAME_ORDER(3), casting='unsafe', subok=True, copy=True)[source]

Copy of the array, cast to a specified type.

property base

Base object if memory is from some other object.

property ctypes

An object to simplify the interaction of the array with the ctypes module.

property data

Buffer object pointing to the start of the array’s data

property dtype

numpy.dtype representing the type stored into this buffer.

property flags

Information about the memory layout of the array.

get(handle=False)[source]

Returns equivalent array on host device, ie. self.

get_T()[source]

Same as self.transpose(), except that self is returned if self.ndim < 2.

get_base()[source]

Base object if memory is from some other object.

get_ctypes()[source]

An object to simplify the interaction of the array with the ctypes module.

get_data()[source]

Buffer object pointing to the start of the array’s data

get_dtype()[source]

numpy.dtype representing the type stored into this buffer.

get_flags()[source]

Information about the memory layout of the array.

get_imag()[source]

The imaginary part of the array.

get_int_ptr()[source]

Return the underlying buffer pointer as an int.

get_itemsize()[source]

Number of bytes per element.

get_nbytes()[source]

Number of bytes in the whole buffer.

get_ndim()[source]

Number of array dimensions.

get_offset()[source]

Offset of array data in buffer.

get_real()[source]

The real part of the array.

get_shape()[source]

The real shape of this buffer.

get_size()[source]

Number of elements in the array.

get_strides()[source]

Tuple of ints that represents the byte step in each dimension when traversing an array.

property imag

The imaginary part of the array.

property int_ptr

Return the underlying buffer pointer as an int.

property itemsize

Number of bytes per element.

lock()[source]

Set tab as a non-writeable array

nanmax(axis=None, out=None)[source]
nanmin(axis=None, out=None)[source]
property nbytes

Number of bytes in the whole buffer.

property ndim

Number of array dimensions.

property offset

Offset of array data in buffer.

put(indices, values, mode='raise')[source]

Set a.flatn = valuesn for all n in indices.

property real

The real part of the array.

set_shape(shape)[source]

Set the shape of this buffer. From the numpy doc: It is not always possible to change the shape of an array without copying the data. If you want an error to be raised if the data is copied, you should assign the new shape to the shape attribute of the array.

property shape

The real shape of this buffer.

property size

Number of elements in the array.

property strides

Tuple of ints that represents the byte step in each dimension when traversing an array.

take(indices, axis=None, out=None, mode='raise')[source]

Return an array formed from the elements of a at the given indices.

tofile(fid, sep='', format='%s')[source]

Write array to a file as text or binary (default). This is a convenience function for quick storage of array data. Information on endianness and precision is lost.

tolist()[source]

Return the array as a possibly nested list.

tostring(order=SAME_ORDER(3))[source]

Construct Python bytes containing the raw data bytes in the array.

unlock()[source]

set tab as a writeable array

view(dtype=None)[source]

New view of array with the same data.